<?php

use think\facade\Route;
//miss路由，定义404
Route::miss(function () {
    @header("http/1.1 404 not found");
    @header("status: 404 not found");
    exit();
});

$domain = ['Access-Control-Allow-Headers' => 'Authorization, Content-Type, If-Match, If-Modified-Since, If-None-Match, If-Unmodified-Since, X-CSRF-TOKEN, X-Requested-With, token, sign'];




//新闻
Route::group('news', function () {
    Route::get('/index', 'news/index');
    Route::get('/info', 'news/info');
    Route::get('/getList', 'news/getList');
});

//授权登录
Route::group('login', function () {
    Route::get('/index', 'login/index');
    Route::post('/Login', 'login/Login');
    Route::rule('/forget', 'login/forget','get|post');
    Route::post('/check', 'login/check');
    Route::post('/miniAppletLogin', 'login/miniAppletLogin');
})->allowCrossDomain($domain);

//支付回调
Route::group('callback', function () {
    Route::rule('/wechatCallback', 'callback/wechatCallback');
    Route::rule('/aliPayOrder', 'callback/aliPayOrder');
    Route::rule('/product_save', 'callback/product_save');
    Route::rule('/RemitCallback', 'callback/RemitCallback');
});

//注册
Route::group('register', function () {
    Route::get('/index', 'register/index');
    Route::post('/save', 'register/save');
})->ext('html');

//商品
Route::group('product', function () {
    Route::get('/index', 'product/index');
    Route::get('/cate', 'product/cate');
    Route::get('/ProductList', 'product/ProductList');
    Route::get('/details', 'product/details');
    Route::post('/submit', 'product/submit')->middleware('verify');
    Route::post('/save', 'product/save')->middleware('verify');
})->allowCrossDomain($domain);

//购物车
Route::group('cart', function () {
    Route::get('/index', 'cart/index');
    Route::post('/add', 'cart/add');
    Route::post('/edit', 'cart/edit');
    Route::post('/submit', 'cart/submit');
})->middleware('verify');

//订单相关
Route::group('order', function () {
    Route::get('/index', 'order/index');
    Route::get('/getTemporary', 'order/getTemporary');
    Route::post('/payment', 'order/payment');
    Route::get('/my_order', 'order/my_order');
    Route::get('/my_order_details', 'order/my_order_details');
    Route::post('/drawback', 'order/drawback');
    Route::get('/getList', 'order/getList');
    Route::post('/submit', 'order/submit');
    Route::post('/confirmPayment', 'order/confirmPayment');
    Route::post('/edit', 'order/edit');
    Route::post('/drawback_save', 'order/drawback_save');
})->allowCrossDomain($domain)->middleware('verify');

//个人中心
Route::group('user', function () {
    Route::get('/get_user', 'user/get_user');
    Route::post('/edit', 'user/edit');
    Route::post('/get_mobile', 'user/get_mobile');
})->allowCrossDomain($domain)->middleware('verify');

//资产 - 我的账户
Route::group('account', function () {
    Route::get('/index', 'account/index');
    Route::get('/record/:type', 'account/record');
    Route::get('/getList', 'account/getList');
})->allowCrossDomain($domain)->middleware('verify');

//充值相关
Route::group('remit', function () {
    Route::get('/remit_account', 'remit/remit_account');
    Route::get('/record', 'remit/record');
    Route::get('/getList', 'remit/getList');
    Route::post('/save', 'remit/save');
})->middleware('verify');

//提现相关
Route::group('draw', function () {
    Route::get('/index', 'draw/index');
    Route::get('/record', 'draw/record');
    Route::get('/getList', 'draw/getList');
    Route::post('/save', 'draw/save');
})->middleware('verify');

//互转相关
Route::group('transfer', function () {
    Route::get('/index', 'transfer/index');
    Route::get('/record', 'transfer/record');
    Route::get('/getList', 'transfer/getList');
    Route::get('/verify', 'transfer/verify');
    Route::post('/save', 'transfer/save');
})->middleware('verify');

//转换相关
Route::group('exchange', function () {
    Route::get('/index', 'exchange/index');
    Route::get('/record', 'exchange/record');
    Route::get('/getList', 'exchange/getList');
    Route::post('/save', 'exchange/save');
})->middleware('verify');

//意见反馈
Route::group('message', function () {
    Route::get('/index', 'message/index');
    Route::post('/save', 'message/save');
})->middleware('verify');

//安全中心
Route::group('security', function () {
    Route::get('/index', 'security/index');
    Route::post('/save', 'security/save');
})->middleware('verify');

//地址相关
Route::group('address', function () {
    Route::get('/index', 'address/index');
    Route::get('/add', 'address/add');
    Route::get('/edit/:id', 'address/edit');
    Route::get('/getArea', 'address/getArea');
    Route::post('/save', 'address/save');
    Route::post('/delete', 'address/delete');
    Route::post('/choice', 'address/choice');
})->middleware('verify');

//上传
Route::group('uploads', function () {
    Route::rule('/uploadImage', 'uploads/uploadImage');
})->allowCrossDomain($domain);
